package handler

import (
	"mall/common/result"
	"net/http"

	"github.com/zeromicro/go-zero/rest/httpx"
	"mall/app/product/cmd/api/internal/logic"
	"mall/app/product/cmd/api/internal/svc"
	"mall/app/product/cmd/api/internal/types"
)

func GetProductDetailHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		var req types.GetProductDetailReq
		if err := httpx.Parse(r, &req); err != nil {
			result.ParamErrorResult(r, w, err)
			return
		}

		l := logic.NewGetProductDetailLogic(r.Context(), svcCtx)
		detail, err2 := l.GetProductDetail(&req)
		result.SendHttp(r, w, detail, err2)
	}
}
